package com.zhongxiangspace.service.impl;

import com.zhongxiangspace.entity.ArticleType;
import com.zhongxiangspace.entity.Articles;
import com.zhongxiangspace.entity.QueryAnalyzer;
import com.zhongxiangspace.mapper.ArticleMapper;
import com.zhongxiangspace.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 文章
 */
@Service
public class ArticleServiceImpl implements ArticleService {


    @Autowired
    private ArticleMapper articleMapper;

    /**
     * 分类
     *
     * @param state
     * @return
     */
    @Override
    public List<ArticleType> queryType(Integer state) {
        return this.articleMapper.queryType(state);
    }

    /**
     * 添加分类
     *
     * @param articleType
     * @return
     */
    @Transactional
    @Override
    public boolean articleTypeAdd(ArticleType articleType) {
        return this.articleMapper.articleTypeAdd(articleType);
    }

    /**
     * 查询单条类型数据
     *
     * @param id
     * @return
     */
    @Override
    public ArticleType queryTypeOne(Integer id) {
        return this.articleMapper.queryTypeOne(id);
    }

    /**
     * 更新状态
     *
     * @param articleType
     * @return
     */
    @Transactional
    @Override
    public boolean updataStatusCode(ArticleType articleType) {
        return this.articleMapper.updataStatusCode(articleType);
    }

    /**
     * 逻辑删除
     *
     * @param id
     * @return
     */
    @Transactional
    @Override
    public boolean delete(Integer id) {
        return this.articleMapper.delete(id);
    }

    /**
     * 更新类型
     *
     * @param articleType
     * @return
     */
    @Transactional
    @Override
    public boolean updataType(ArticleType articleType) {
        return this.articleMapper.updataType(articleType);
    }

    /**
     * 添加文章内容
     *
     * @param articles
     * @return
     */
    @Transactional
    @Override
    public boolean insertArticles(Articles articles) {
        return this.articleMapper.insertArticles(articles);
    }

    /**
     * 获取所有的文章
     *
     * @param queryAnalyzer
     * @return
     */
    @Override
    public List<Map<String, Object>> articlesAll(QueryAnalyzer queryAnalyzer) {
        return this.articleMapper.articlesAll(queryAnalyzer);
    }

    /**
     * 逻辑删除文章
     * @param id
     * @return
     */
    @Override
    @Transactional
    public boolean deleteDetails(Integer id) {
        return this.articleMapper.deleteDetails(id);
    }

    /**
     * 获取单条文章data
     * @param id
     * @return
     */
    @Override
    public Articles queryOne(Integer id) {
            return this.articleMapper.queryOne(id);
    }

    /**
     * 是否热门
     * @param articles
     * @return
     */
    @Override
    @Transactional
    public boolean updataStateHot(Articles articles) {
        return this.articleMapper.updataStateHot(articles);
    }

    /**
     * 上下线
     * @param articles
     * @return
     */
    @Transactional
    @Override
    public boolean updataStates(Articles articles) {
        return this.articleMapper.updataStates(articles);
    }

    /**
     * 更新文章
     * @param articles
     * @return
     */
    @Override
    public boolean updataDetails(Articles articles) {
        return this.articleMapper.updataDetails(articles);
    }

    /**
     * 文章资讯
     * @param articleQueryAnalyzer
     * @return
     */
    @Override
    public List<Map<String, Object>> queryArticles(QueryAnalyzer articleQueryAnalyzer) {
        return this.articleMapper.queryArticles(articleQueryAnalyzer);
    }

    /**
     * 上篇文章
     * @param id
     * @return
     */
    @Override
    public Articles queryOneUP(Integer id) {
        return this.articleMapper.queryOneUP(id);
    }

    /**
     * 下篇文章
     * @param id
     * @return
     */
    @Override
    public Articles queryOneDOWN(Integer id) {
        return this.articleMapper.queryOneDOWN(id);
    }

}
